package org.opens.service.fallback;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.opens.entity.Product;
import org.opens.service.ProductService;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ProductServiceFallbackFactory implements FallbackFactory<ProductService> {

    @Override
    public ProductService create(Throwable cause) {
        return new ProductService() {

            @Override
            public Product findById(Integer id) {
                log.error("fallback factory bean catch this error {}", cause.getMessage());
                return null;
            }
        };
    }
}
